package br.com.sgh.dao;

import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

public class GeneroDAO<T> extends DAO<T> {

    public GeneroDAO(Class<T> classe, Session session) {
        super(classe, session);
    }

    public List<T> generos() {
        List<T> generos = getEntitys();
        return generos;
    }

    public List<T> pesquisaGenero(String descricao) {
        Criterion filtro = Restrictions.like("descricao", "%" + descricao + "%");
        Criteria criteria = criaCriteria().addOrder(Order.asc("descricao"));
        List<T> lista = criteria.add(filtro).list();
        return lista;
    }
}
